package com.ylp.sys.auth.utils;


import cn.hutool.crypto.digest.BCrypt;

/**
     * <p>BCrypt加解密工具类</p>
     **/
public class BCryptUtils {

       public static String encode(String password) {
           String salt = BCrypt.gensalt();
           return BCrypt.hashpw(password, salt);
       }

       public static boolean checkpw(String password, String hashPassword) {
           return BCrypt.checkpw(password, hashPassword);
       }


       public static void main(String[] args) {
           String haspwd = encode("123456");
           System.out.println(haspwd);
           System.out.println(checkpw("123456", haspwd));
           System.out.println(checkpw("123456", "$2a$10$grLKYPtiZ190gOn6.TfcXuDJjL2PsA5QHe59UfNXx0yx.hCTPvWp6"));

       }

}
